from com.mysqlconnection import mysql_connect
from  init_cs import dictfetchall
Host_list_sql='SELECT  host_id,NAME,VALUE FROM host_details WHERE NAME="url" OR NAME="password"'

    
def list_Hostinfo():
    cnn=mysql_connect()
    cnn.execute(Host_list_sql)
    return dictfetchall(cnn)

def get_hostinfo():
    temp = list_Hostinfo()
    retlist = []   
    for t in temp:
        result = {}    
        for t2 in temp:
            if t["host_id"] == t2["host_id"]:
                result["host_id"] = t["host_id"]
                result[t2["NAME"]] = t2["VALUE"]
        if not result in retlist:
            retlist.append(result)
    return retlist